Skip to content

Conversation

logaretm
Copy link
Collaborator

@logaretm logaretm commented Oct 9, 2025

This pull request introduces automatic instrumentation for database queries in Nuxt applications in server side handlers using Sentry.

Implementation Details

  • Instruments database .sql, .prepare and .exec calls.
  • Adds breadcrumbs and spans following cloudflare's D1 implementation.

This relies on the work done in #17858 and #17886

Copy link

linear bot commented Oct 9, 2025

@logaretm logaretm force-pushed the awad/js-1036-nuxtnitro-instrument-database-sqlite branch 4 times, most recently from 7f29d2e to 55ca147 Compare October 15, 2025 10:17
@logaretm logaretm changed the base branch from develop to awad/js-1023-nuxtnitro-instrument-cache October 15, 2025 10:17
@logaretm logaretm force-pushed the awad/js-1023-nuxtnitro-instrument-cache branch from c844c9e to 17482e2 Compare October 15, 2025 10:31
@logaretm logaretm force-pushed the awad/js-1036-nuxtnitro-instrument-database-sqlite branch from 55ca147 to 76ad329 Compare October 15, 2025 10:32
Copy link
Contributor

github-actions bot commented Oct 15, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 24.64 kB added added
@sentry/browser - with treeshaking flags 23.14 kB added added
@sentry/browser (incl. Tracing) 40.85 kB added added
@sentry/browser (incl. Tracing, Replay) 79.21 kB added added
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 68.92 kB added added
@sentry/browser (incl. Tracing, Replay with Canvas) 83.91 kB added added
@sentry/browser (incl. Tracing, Replay, Feedback) 96.08 kB added added
@sentry/browser (incl. Feedback) 41.33 kB added added
@sentry/browser (incl. sendFeedback) 29.3 kB added added
@sentry/browser (incl. FeedbackAsync) 34.26 kB added added
@sentry/react 26.35 kB added added
@sentry/react (incl. Tracing) 42.84 kB added added
@sentry/vue 29.13 kB added added
@sentry/vue (incl. Tracing) 42.64 kB added added
@sentry/svelte 24.66 kB added added
CDN Bundle 26.94 kB added added
CDN Bundle (incl. Tracing) 41.53 kB added added
CDN Bundle (incl. Tracing, Replay) 77.8 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) 83.28 kB added added
CDN Bundle - uncompressed 78.95 kB added added
CDN Bundle (incl. Tracing) - uncompressed 123.07 kB added added
CDN Bundle (incl. Tracing, Replay) - uncompressed 238.23 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 251 kB added added
@sentry/nextjs (client) 44.9 kB added added
@sentry/sveltekit (client) 41.27 kB added added
@sentry/node-core 50.78 kB added added
@sentry/node 154.4 kB added added
@sentry/node - without tracing 92.65 kB added added
@sentry/aws-serverless 106.35 kB added added

@logaretm logaretm force-pushed the awad/js-1023-nuxtnitro-instrument-cache branch from 17482e2 to 65277c7 Compare October 15, 2025 10:43
@logaretm logaretm force-pushed the awad/js-1036-nuxtnitro-instrument-database-sqlite branch from 68758a1 to 9599b1d Compare October 15, 2025 10:45
@logaretm logaretm marked this pull request as ready for review October 15, 2025 12:26
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@logaretm logaretm force-pushed the awad/js-1023-nuxtnitro-instrument-cache branch from 65277c7 to 604de80 Compare October 15, 2025 20:55
@logaretm logaretm force-pushed the awad/js-1036-nuxtnitro-instrument-database-sqlite branch from 7c1e749 to f9dcb00 Compare October 15, 2025 20:55
Copy link
Member

@s1gr1d s1gr1d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, it looks good. Just have some small comments

*/
export default defineNitroPlugin(() => {
try {
debug.log('@sentry/nuxt: Instrumenting databases...');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add conditionals to the debug.log statements so they are only shown in debug mode. And I think the log already includes [Sentry] at the start (but not 100%) so we could just simplify it so it shows something like this in the end: [Sentry] [Nitro Database Plugin]: Instrumenting databases...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forget the note about conditionally calling it. debug already handles that

https://github.com/getsentry/sentry-javascript/pull/17858/files#r2418913504

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the messages, and I think we cleared debug.log being safe to use directly since it does the check on its own.

for (const instance of databaseInstances) {
debug.log('@sentry/nuxt: Instrumenting database instance:', instance);
const db = useDatabase(instance);
instrumentDatabase(db);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this only runs once. But if it doesn't: Maybe we need a conditional here to check whether the database was already instrumented.

@logaretm logaretm force-pushed the awad/js-1023-nuxtnitro-instrument-cache branch from 604de80 to f1dd874 Compare October 16, 2025 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants